package com.daocao.hua.view;

import android.text.TextUtils;

import com.daocao.hua.R;
import com.daocao.hua.activity.Application;

/**
 * 银行卡资源
 * Created by Master.Dong on 2016/4/6 0006.
 */
public class BankViewItem {

//    private static Context Application.getInstance();

//    public static BankViewItem instance;
//
//    public static BankViewItem getInstance(Context context) {
//        if (instance == null) {
//            synchronized (BankViewItem.class) {
//                if (instance == null) {
//                    instance = new BankViewItem(context);
//                }
//            }
//        }
//        return instance;
//    }

//    public BankViewItem(Context context) {
//        Application.getInstance() = context;
//    }

    public  int[] bankImg = {R.mipmap.bank_default, R.mipmap.guangfa, R.mipmap.huaxia, R.mipmap.shanghai, R.mipmap.xingye, R.mipmap.zhaoshang, R.mipmap.gongshang, R.mipmap.nongye, R.mipmap.zhongguoyinhang, R.mipmap.zhongxin, R.mipmap.minsheng, R.mipmap.jianshe, R.mipmap.guangda, R.mipmap.pufa, R.mipmap.youzheng, R.mipmap.nongcun, R.mipmap.jiaotong};
    public  int[] bankColor = {R.color.bank_default, R.color.guangda, R.color.huaxia, R.color.shanghai, R.color.xingye, R.color.zhaoshang, R.color.gongshang, R.color.nongye, R.color.zhongguoyinhang, R.color.zhongxin, R.color.minsheng, R.color.jianshe, R.color.guangda, R.color.pufa, R.color.youzheng, R.color.nongcun, R.color.jiaotong};


    /**
     * 获取银行资源
     *
     * @param bankName
     */
    public int getBankRes(String bankName) {
        try {
//            icon.setImageDrawable(ContextCompat.getDrawable(Application.getInstance(), bankImg[0]));
            if (TextUtils.isEmpty(bankName)) return 0;
            int id = 0;
            if (bankName.contains(Application.getInstance().getResources().getString(R.string.guangfa))) id = 1;
            if (bankName.contains(Application.getInstance().getResources().getString(R.string.huaxia))) id = 2;
            if (bankName.contains(Application.getInstance().getResources().getString(R.string.shanghai))) id = 3;
            if (bankName.contains(Application.getInstance().getResources().getString(R.string.xingye))) id = 4;
            if (bankName.contains(Application.getInstance().getResources().getString(R.string.zhaoshang))) id = 5;
            if (bankName.contains(Application.getInstance().getResources().getString(R.string.gongshang))) id = 6;
            if (bankName.contains(Application.getInstance().getResources().getString(R.string.nongye))) id = 7;
            if (bankName.contains(Application.getInstance().getResources().getString(R.string.zhongguoyinhang)))
                id = 8;
            if (bankName.contains(Application.getInstance().getResources().getString(R.string.zhongxin))) id = 9;
            if (bankName.contains(Application.getInstance().getResources().getString(R.string.minsheng))) id = 10;
            if (bankName.contains(Application.getInstance().getResources().getString(R.string.jianshe))) id = 11;
            if (bankName.contains(Application.getInstance().getResources().getString(R.string.guangda))) id = 12;
            if (bankName.contains(Application.getInstance().getResources().getString(R.string.pufa))) id = 13;
            if (bankName.contains(Application.getInstance().getResources().getString(R.string.youzheng))) id = 14;
            if (bankName.contains(Application.getInstance().getResources().getString(R.string.nongcun))) id = 15;
            if (bankName.contains(Application.getInstance().getResources().getString(R.string.jiaotong))) id = 16;

//            icon.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), bankImg[id]));
//            bankView.setCardBackgroundColor(ContextCompat.getColor(getApplicationContext(), bankColor[id]));

            return id;
        } catch (Exception e) {
            e.printStackTrace();
            return 0;
        }
    }


}
